package com.sch.www.feign;

import com.sch.www.common.core.ServiceConstant;
import com.sch.www.common.core.web.ResponseBean;
import com.sch.www.common.feign.CustomFeignConfig;
import com.sch.www.entity.*;
import com.sch.www.feign.factory.UserServiceClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户服务
 *
 * @author tangyi
 * @date 2018-12-30 23:21
 */


@FeignClient(value = ServiceConstant.USER_API_SERVER, configuration = CustomFeignConfig.class, fallbackFactory = UserServiceClientFallbackFactory.class)
public interface UserApi {


    /**
     * 根据用户名获取用户详细信息
     *
     * @param username username
     * @return SysUser
     * @author tangyi
     * @date 2019/03/17 12:14
     */
    @GetMapping("/v1/user/findUserByUsername/{username}")
    SysUser findUserByUsername(@PathVariable("username") String username);

    /** 
     * 获取当前用户的信息
     *
     * @return ResponseBean
     * @author tangyi
     * @date 2019/03/23 23:44
     */
    @GetMapping("/v1/user/info")
    ResponseBean<SysUser> info();

    /**
     * 根据用户id获取用户
     *
     * @param sysUser sysUser
     * @return SysUser
     */
    @RequestMapping(value = "/v1/user/findById", method = RequestMethod.POST)
    ResponseBean<List<SysUser>> findUserById(@RequestBody SysUser sysUser);

    /**
     * 根据部门id获取部门
     *
     * @param deptVo deptVo
     * @return ResponseBean
     */
    @RequestMapping(value = "/v1/dept/findById", method = RequestMethod.POST)
    ResponseBean<List<SysDept>> findDeptById(@RequestBody SysDept deptVo);

    /**
     * 根据ID删除附件
     *
     * @param id id
     * @return ResponseBean
     * @author tangyi
     * @date 2019/01/01 20:44
     */
    @DeleteMapping("/v1/attachment/{id}")
    ResponseBean<Boolean> deleteAttachment(@PathVariable(value = "id") String id);

    /**
     * 根据附件id获取附件
     *
     * @param attachmentVo attachmentVo
     * @return ResponseBean
     */
    @RequestMapping(value = "/v1/attachment/findById", method = RequestMethod.POST)
    ResponseBean<List<SysAttachment>> findAttachmentById(@RequestBody SysAttachment attachmentVo);

    /**
     * 保存日志
     *
     * @param log log
     * @return ResponseBean
     * @author tangyi
     * @date 2019/03/23 23:26
     */
    @PostMapping("/v1/log")
    ResponseBean<Boolean> saveLog(@RequestBody SysLog log);

    /**
     * 根据角色查找菜单
     *
     * @param role 角色
     * @return List
     * @author tangyi
     * @date 2019/04/08 20:42
     */
    @GetMapping("/v1/menu/findMenuByRole/{role}")
    List<SysMenu> findMenuByRole(@PathVariable("role") String role);
    

}
